package com.googlecode.imanager.client.event;

import com.googlecode.imanager.client.Control;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public abstract class Event {
    
    boolean simulated;
    private boolean preventDefault;
    private boolean cancelBubble;
    private Control target;
    
    public Event(Control target) {
        setTarget(target);
    }
    
    protected void reset(){
        preventDefault = false;
        cancelBubble = false;
    }
    
    public abstract EventType getEventType();
    
    protected void setTarget(Control target) {
        if (target == null){
            throw new IllegalArgumentException("target");
        }
        this.target = target;
    }

    public Control getTarget() {
        return target;
    }

    public Event getCause(){
        return null;
    }

    public final boolean isSimulated() {
        return simulated;
    }

    public boolean isPreventDefault() {
        return preventDefault;
    }

    public void setPreventDefault(boolean preventDefault) {
        this.preventDefault = preventDefault;
    }

    public boolean isCancelBubble() {
        return cancelBubble;
    }

    public void setCancelBubble(boolean cancelBubble) {
        this.cancelBubble = cancelBubble;
    }
    
}
